package com.mspbots.core.script.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.mspbots.core.AbstractBaseController;
import com.mspbots.core.script.model.ScriptParam;
import com.mspbots.core.script.model.SystemScript;
import com.mspbots.core.script.service.SystemScriptService;
import org.springframework.web.bind.annotation.*;

import java.util.concurrent.Callable;

/**
 * com.mspbots.core.script.controller.SystemScriptController
 *
 * @author Jason
 * @date 2019/12/16
 **/
@RestController
@RequestMapping("system-script")
public class SystemScriptController extends AbstractBaseController<SystemScript, SystemScriptService> {


    @Override
    @GetMapping(path = "/list")
    public Callable selectList(SystemScript queryParams) {
        QueryWrapper<SystemScript> queryWrapper = new QueryWrapper<>(queryParams);
        return () -> service.querylist(queryWrapper);
    }

    @Override
    @PostMapping
    public Callable insert(@RequestBody SystemScript entity) {
        return () -> service.saveOrUpdateScript(entity);
    }

    @GetMapping(path = "/list-name")
    public Callable list(SystemScript queryParams) {
        QueryWrapper<SystemScript> queryWrapper = new QueryWrapper<>(queryParams);
        queryWrapper.select("id", "name");
        return () -> service.list(queryWrapper);
    }

    @GetMapping(path = "/addparambyname")
    public Callable addParamByName(ScriptParam queryParams) {
        return () -> service.addParamByName(queryParams);
    }

}
